package client;

import util.GameConstants;

public class FireSentinel extends Summon{
	public int turnsUntilShoot;
	/** Turns until the summon expires and dies. */
	public int turnsLeft;
	public FireSentinel(double xCoord, double yCoord, int playerID) {
		super(xCoord, yCoord, playerID);
		turnsUntilShoot = GameConstants.sentinelFireRate;
		turnsLeft = GameConstants.sentinelDuration;
	}
	
	@Override
	public void act(GameModel model) {
		turnsLeft--;
		if(turnsLeft<=0)
			expire(model);
		turnsUntilShoot--;
		if(turnsUntilShoot<=0) {
			int targetPlayerID = model.getEnemyNearest(playerID, xPos, yPos, Double.MAX_VALUE);
			Player target = model.players[targetPlayerID];
			model.addProjectile(playerID, xPos, yPos, 2, target.xLoc, target.yLoc, GameConstants.sentinelShotSpeed);
			turnsUntilShoot = GameConstants.sentinelFireRate;
			
		}
		
	}

}
